﻿using doveData.XmlScripts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace doveData
{
    class ConsoleControl
    {

        public static void Intro()
        {
            DataBase();
        }

        static void Line()
        {
            LineXml myLine = new LineXml();
            int num;
            while (true)
            {
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.WriteLine("\t\t\t\t\t*      欢迎来到鸽线路服务中心！    *");
                Console.WriteLine("\t\t\t\t\t*        请输入操作码选择服务：    *");
                Console.WriteLine("\t\t\t\t\t*         1.查询地铁线路信息       *");
                Console.WriteLine("\t\t\t\t\t*         2.增加新的线路信息       *");
                Console.WriteLine("\t\t\t\t\t*         3.修改已有线路信息       *");
                Console.WriteLine("\t\t\t\t\t*         4.删除已有线路信息       *");
                Console.WriteLine("\t\t\t\t\t*         0.退出操作               *");
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.Write("\t\t\t\t\t");
                try
                {
                    num = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("\t\t\t\t\t抱歉，请输入有效的操作码");
                    continue;
                }
                switch (num)
                {
                    case 1:
                        {
                            myLine.Output();
                            break;
                        }
                    case 2:
                        {
                            myLine.AddXElement();
                            break;
                        }
                    case 3:
                        {
                            myLine.ModifyElement();
                            break;
                        }
                    case 4:
                        {
                            myLine.DeleteElement();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("\t\t\t\t\t输入指令有误！");
                            break;
                        }
                }
                if (num == 0) break;
            }
        }

        static void Hotel()
        {
            HotelXml myHotel = new HotelXml();
            int num;
              while (true)
            {
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.WriteLine("\t\t\t\t\t*      欢迎来到鸽酒店服务中心！    *");
                Console.WriteLine("\t\t\t\t\t*        请输入操作码选择服务：    *");
                Console.WriteLine("\t\t\t\t\t*         1.查询酒店信息           *");
                Console.WriteLine("\t\t\t\t\t*         2.增加新的酒店信息       *");
                Console.WriteLine("\t\t\t\t\t*         3.修改已有酒店信息       *");
                Console.WriteLine("\t\t\t\t\t*         4.删除已有酒店信息       *");
                Console.WriteLine("\t\t\t\t\t*         0.退出操作               *");
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.Write("\t\t\t\t\t");
                try
                {
                    num = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("\t\t\t\t\t抱歉，请输入有效的操作码");
                    continue;
                }
                switch (num)
                {
                    case 1:
                        {
                            myHotel.Output();
                            break;
                        }
                    case 2:
                        {
                            myHotel.AddXElement();
                            break;
                        }
                    case 3:
                        {
                            myHotel.ModifyElement();
                            break;
                        }
                    case 4:
                        {
                            myHotel.DeleteElement();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("\t\t\t\t\t输入指令有误！");
                            break;
                        }
                }
                if (num == 0) break;
            }
        }

        static void Market()
        {
            MarketXml myMarket = new MarketXml();
            int num;
            while (true)
            {
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.WriteLine("\t\t\t\t\t*      欢迎来到鸽商店服务中心！    *");
                Console.WriteLine("\t\t\t\t\t*        请输入操作码选择服务：    *");
                Console.WriteLine("\t\t\t\t\t*         1.查询商店信息           *");
                Console.WriteLine("\t\t\t\t\t*         2.增加新的商店信息       *");
                Console.WriteLine("\t\t\t\t\t*         3.修改已有商店信息       *");
                Console.WriteLine("\t\t\t\t\t*         4.删除已有商店信息       *");
                Console.WriteLine("\t\t\t\t\t*         0.退出操作               *");
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.Write("\t\t\t\t\t");
                try
                {
                    num = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("\t\t\t\t\t抱歉，请输入有效的操作码");
                    continue;
                }
                switch (num)
                {
                    case 1:
                        {
                            myMarket.Output();
                            break;
                        }
                    case 2:
                        {
                            myMarket.AddXElement();
                            break;
                        }
                    case 3:
                        {
                            myMarket.ModifyElement();
                            break;
                        }
                    case 4:
                        {
                            myMarket.DeleteElement();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("\t\t\t\t\t输入指令有误！");
                            break;
                        }
                }
                if (num == 0) break;
            }
        }

        static void Food()
        {
            FoodXml myFood = new FoodXml();
            int num;
            while (true)
            {
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.WriteLine("\t\t\t\t\t*      欢迎来到鸽饭店服务中心！    *");
                Console.WriteLine("\t\t\t\t\t*        请输入操作码选择服务：    *");
                Console.WriteLine("\t\t\t\t\t*         1.查询饭店信息           *");
                Console.WriteLine("\t\t\t\t\t*         2.增加新的饭店信息       *");
                Console.WriteLine("\t\t\t\t\t*         3.修改已有饭店信息       *");
                Console.WriteLine("\t\t\t\t\t*         4.删除已有饭店信息       *");
                Console.WriteLine("\t\t\t\t\t*         0.退出操作               *");
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.Write("\t\t\t\t\t");
                try
                {
                    num = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("\t\t\t\t\t抱歉，请输入有效的操作码");
                    continue;
                }
                switch (num)
                {
                    case 1:
                        {
                            myFood.Output();
                            break;
                        }
                    case 2:
                        {
                            myFood.AddXElement();
                            break;
                        }
                    case 3:
                        {
                            myFood.ModifyElement();
                            break;
                        }
                    case 4:
                        {
                            myFood.DeleteElement();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("\t\t\t\t\t输入指令有误！");
                            break;
                        }
                }
                if (num == 0) break;
            }
        }

        static void DataBase()
        {
            int flag = -1;
            while (true)
            {
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.WriteLine("\t\t\t\t\t*      欢迎来到鸽地图服务中心！    *");
                Console.WriteLine("\t\t\t\t\t*        请输入操作码选择服务：    *");
                Console.WriteLine("\t\t\t\t\t*         1.查询地铁线路信息       *");
                Console.WriteLine("\t\t\t\t\t*         2.查询酒店数据信息       *");
                Console.WriteLine("\t\t\t\t\t*         3.查询商店数据信息       *");
                Console.WriteLine("\t\t\t\t\t*         4.查询饭店数据信息       *");
                Console.WriteLine("\t\t\t\t\t************************************");
                Console.Write("\t\t\t\t\t");
                try
                {
                    flag = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("\t\t\t\t\t抱歉，请输入有效的操作码");
                    continue;
                }
                switch (flag)
                {
                    case 1:
                        Line();
                        break;
                    case 2:
                        Hotel();
                        break;
                    case 3:
                        Market();
                        break;
                    case 4:
                        Food();
                        break;
                    default:
                        Console.WriteLine("\t\t\t\t\t抱歉，您的输入有误，请重试");
                        break;
                }
            }
        }

        

    }
}
